package com.soft.javase.ch10.test.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author wangzhisen
 * @Desc TODO
 * @date 2025/5/7
 * 3.筛选员工中工资高于8000的人，并形成新的集合
 */
class Employee {
    private String name;
    private int age;
    private double salary;

    public Employee(String name, int age, double salary) {
        this.name = name;
        this.age = age;
        this.salary = salary;
    }

    // getters
    public String getName() { return name; }
    public int getAge() { return age; }
    public double getSalary() { return salary; }
}

public class HighSalaryEmployees {
    public static void main(String[] args) {
        List<Employee> employees = new ArrayList<>();
        employees.add(new Employee("张三", 25, 7500));
        employees.add(new Employee("李四", 30, 8500));
        employees.add(new Employee("王五", 28, 9000));
        employees.add(new Employee("赵六", 35, 7800));

        List<Employee> highSalaryEmployees = employees.stream()
                .filter(e -> e.getSalary() > 8000)
                .collect(Collectors.toList());

        System.out.println("工资高于8000的员工:");
        highSalaryEmployees.forEach(e ->
                System.out.println(e.getName() + ": " + e.getSalary()));
    }
}
